package cn.itsource.org.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.org.domain.User;
import cn.itsource.org.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/checkphone/{phone}")
    @ApiOperation(value = "验证手机号")
    public AjaxResult checkPhone(@PathVariable("phone") String phone ){
         return userService.checkPhone(phone);
    }

    @GetMapping("/sendmobilecode/{phone}")
    @ApiOperation(value = "获取验证码")
    public AjaxResult sendMobileCode(@PathVariable("phone") String phone ){
         return userService.sendMobileCode(phone);
    }

    @PostMapping
    @ApiOperation(value = "注册账号")
    public AjaxResult register(@RequestBody User user){
        return userService.register(user);
    }
}
